{% extends 'plugins/plugin_base.html' %}{% load i18n %}
{% block content %}
    <h2>{% trans "Version" %}: {{ version }}</h2>
    <div class="pull-right"><a href="{% url "version_download" version.plugin.package_name version.version %}" class="btn btn-primary"><i class="icon-download-alt icon-white"></i> {% trans "Download" %}</a></div>

    {% if not version.created_by.is_active %}
    <div class="alert alert-error">
        {% trans "The plugin author has been blocked." %}
    </div>
    {% endif %}


    <ul class="nav nav-tabs" id="plugintab">
        <li class="active"><a href="#details-tab" data-toggle="tab">{% trans "Details" %}</a></li>
        <li><a href="#manage-tab" data-toggle="tab">{% trans "Manage" %}</a></li>
    </ul>

    <div class="tab-content">
        <div class="tab-pane active" id="details-tab">
            <dl class="dl-horizontal">
                {% if version.changelog %}<dt>{% trans "Changelog" %}</dt><dd><pre>{{ version.changelog|wordwrap:80 }}</pre></dd>{% endif %}
                <dt>{% trans "Approved" %}</dt><dd>{{ version.approved|yesno }}</dd>
                <dt>{% trans "Author" %}</dt><dd>{{ version.created_by }}</dd>
                <dt>{% trans "Uploaded" %}</dt><dd>{{ version.created_on }}</dd>
                <dt>{% trans "Minimum QGIS version" %}</dt><dd>{{ version.min_qg_version }}</dd>
                <dt>{% trans "Maximum QGIS version" %}</dt><dd>{{ version.max_qg_version }}</dd>
                <dt>{% trans "External dependencies (PIP install string)" %}</dt><dd>{{ version.external_deps }}</dd>
                <dt {% if version.experimental %}class="warning"{% endif %}>{% trans "Experimental" %}</dt><dd>{{ version.experimental|yesno }}</dd>
            </dl>
        </div>
        <!-- set to active otherwise the wrong tab is selected, don't ask me why... -->
        <div class="tab-pane" id="manage-tab">
            <h4>{% trans "Version management"%}</h4>
            {% if user.is_staff or user in version.plugin.editors %}
            <a class="btn btn-primary" href="{% url "version_update" version.plugin.package_name version.version %}">{% trans "Edit" %}</a>
            <a class="btn btn-danger" href="{% url "version_delete" version.plugin.package_name version.version %}">{% trans "Delete" %}</a>
            {% endif %}
            <a class="btn btn-primary" href="{% url "plugin_detail" version.plugin.package_name %}">{% trans "Plugin details" %}</a>

    {% if user.is_staff or user in version.plugin.approvers %}
            <h4>{% trans "Version approval"%}</h4>
            <form class="form-inline" method="post" action="{% url "version_manage" version.plugin.package_name version.version %}">{% csrf_token %}
                {% if not version.approved %}<input class="btn btn-success" type="submit" name="version_approve" id="version_approve" value="{% trans "Approve this version" %}" />&nbsp;{% else %}<input class="btn btn-warning" type="submit" name="version_unapprove" id="version_unapprove" value="{% trans "Unapprove this version" %}" />{% endif %}
            </form>
            {% if user.is_staff %}
            <h4>{% trans "Author management"%}</h4>
            <form class="form-inline"  method="post" action="{% url "user_permissions_manage" version.plugin.created_by.username %}">{% csrf_token %}
                {% if version.created_by.is_active %}
                <input class="btn btn-danger" type="submit" id="user_block" name="user_block" value="{% trans "Block author" %}" />{% else %}
                <input class="btn btn-warning" type="submit" id="user_unblock" name="user_unblock" value="{% trans "Unblock author" %}" />
                {% endif %}
                {% if version.created_by.is_active %}
                {% if not version.plugin.trusted %}<input class="btn btn-success"  type="submit" id="user_trust" name="user_trust" value="{% trans "Trust author" %}" />{% else %}
                <input class="btn btn-warning" type="submit" id="user_untrust" name="user_untrust" value="{% trans "Untrust author" %}" />{% endif %}
                {% endif %}
            </form>
        {% endif %}
        </div>
    {% endif %}
    </div><!-- end tab content -->

<!--
<script type="text/javascript">
    jQuery(document).ready(function ($) {
        $('#plugintab a:first').tab('show');
    });
</script>
-->

{% endblock %}
